#include "vector_float.h"

//private
void vector_float::create_vector(int s){
	if (s > 0){
		vptr = new float[s];
		size = s;
	}
	else if (s == 0){
		vptr = nullptr;
		size = 0;
	}
	else{
		cout << "Invalid size!" << endl;
		size = 0;
	}
}

void vector_float::delete_vector(){
	delete []vptr;
	size = 0;
}

//public
vector_float::vector_float()
{
	create_vector(0);
}

vector_float::vector_float(int s){
	create_vector(s);
}

vector_float::~vector_float()
{
	delete_vector();
}

void vector_float::set(float value, int index){
	if (index <= size){
		vptr[index] = value;
	}
	else{
		cout << "Invalid index!" << endl;
	}
}

void vector_float::read_from_keyboard(){
	for (int i = 0; i < size; i++){
		cout << "Insert value (" << i + 1 << "/" << size << "): ";
		cin >> vptr[i];
	}
}

void vector_float::print(){
	cout << "[" << vptr[0];
	for (int i = 1; i < size; i++){
		cout << ", " << vptr[i];
	}
	cout << "]" << endl;
}